home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Dots & Pixels / sources / window.cp < prev   
Text File  |  1995-09-29  |  2KB  |  75 lines

  1. #include <Windows.h>
  2. #include <QDOffscreen.h>
  3.  
  4. #include <Fonts.h>
  5. #include <Packages.h>
  6. #include <SegLoad.h>
  7. #include <ToolUtils.h>
  8. #include <TextEdit.h>
  9.  
  10. #include "general.h"
  11. #include "port.h"
  12. #include "window.h"
  13.  
  14. window::window( short breedte, short hoogte, Str255 naam) : port()
  15. {
  16.     SetRect( &myRect, 0, 0, breedte, hoogte);
  17.     
  18.     Rect theRect = myRect;
  19.  
  20.     short * const MBarHeight = (short *)0x0BAA;
  21.     const short offset = 2 * (*MBarHeight);
  22.     
  23.     OffsetRect( &theRect, offset, offset); // moves window from below menubar (on most systems)
  24.     makeOne( theRect, naam);
  25. }
  26.  
  27. window::window( short breedte, short hoogte, short xPos, short yPos, Str255 naam)
  28. {
  29.     SetRect( &myRect, 0, 0, breedte, hoogte);
  30.     
  31.     Rect theRect = myRect;
  32.  
  33.     OffsetRect( &theRect, xPos, yPos);
  34.     makeOne( theRect, naam);
  35. }
  36.  
  37. void window::makeOne( const Rect &theRect, const Str255 naam)
  38. {
  39.     myWindow = NewCWindow( &myWindowRecord, &theRect, naam, 0, 0, (WindowPtr)-1, 1, 0);
  40.     show();
  41.     SetPort( myWindow);
  42.     GetGWorld( &myGWorldPtr, &myGDHandle);
  43.     #ifndef _APPL_
  44.         #ifndef THINK_CPLUS
  45.             //
  46.             // signal 'application' to close this window on exit
  47.             //
  48.             SetWRefCon( myWindow, 'vens');
  49.         #endif
  50.     #endif
  51.     myRect = myWindow->portRect;
  52.     myPix  = (PixMapPtr)(&(myWindow->portBits));
  53. }
  54.  
  55. window::~window()
  56. {
  57.     CloseWindow( myWindow); // we passed our own WindowRecord => don't call DisposeWindow
  58. }
  59.  
  60. void window::show() const
  61. {
  62.     ShowWindow( myWindow);
  63.     SelectWindow( myWindow);
  64. }
  65.  
  66. void window::hide() const
  67. {
  68.     HideWindow( myWindow);
  69. }
  70.  
  71. void window::moveto( int x, int y) const
  72. {
  73.     MoveWindow( myWindow, x, y, false);    // do not make this the active window
  74. }
  75.